/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author YDZ
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '../model/baseModel';
import { UploadApiResult } from '../sys/upload';
import { UploadFileParams } from '/#/axios';

const { ctxPath, adminPath } = useGlobSetting();

export interface CoreKhlxr extends BasicModel<CoreKhlxr> {
  khlxrLxrbm?: string; // 联系人编码
  khlxrLxrmc?: string; // 联系人名称
  khlxrBm?: string; // 部门
  khlxrLxdh?: string; // 联系电话
  khlxrMrlxr?: string; // 默认联系人
  parentId?: string; // 客户编码
}

export const coreKhlxrList = (params?: CoreKhlxr | any) =>
  defHttp.get<CoreKhlxr>({ url: adminPath + '/bas/cus/coreKhlxr/list', params });

export const coreKhlxrListData = (params?: CoreKhlxr | any) =>
  defHttp.post<Page<CoreKhlxr>>({ url: adminPath + '/bas/cus/coreKhlxr/listData', params });

export const coreKhlxrForm = (params?: CoreKhlxr | any) =>
  defHttp.get<CoreKhlxr>({ url: adminPath + '/bas/cus/coreKhlxr/form', params });

export const coreKhlxrSave = (params?: any, data?: CoreKhlxr | any) =>
  defHttp.postJson<CoreKhlxr>({ url: adminPath + '/bas/cus/coreKhlxr/save', params, data });

export const coreKhlxrImportData = (
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) =>
  defHttp.uploadFile<UploadApiResult>(
    {
      url: ctxPath + adminPath + '/bas/cus/coreKhlxr/importData',
      onUploadProgress,
    },
    params,
  );

export const coreKhlxrDisable = (params?: CoreKhlxr | any) =>
  defHttp.get<CoreKhlxr>({ url: adminPath + '/bas/cus/coreKhlxr/disable', params });

export const coreKhlxrEnable = (params?: CoreKhlxr | any) =>
  defHttp.get<CoreKhlxr>({ url: adminPath + '/bas/cus/coreKhlxr/enable', params });

export const coreKhlxrDelete = (params?: CoreKhlxr | any) =>
  defHttp.get<CoreKhlxr>({ url: adminPath + '/bas/cus/coreKhlxr/delete', params });

export const coreKhlxrTreeData = (params?: CoreKhlxr | any) =>
  defHttp.get<CoreKhlxr>({ url: adminPath + '/bas/cus/coreKhlxr/treeData', params });
